<?php
function solveto_preprocess_node(&$variables) {
    if(isset($variables['node'])){
        $node = $variables['node'];
        // Node type Project
        if($node->type == 'project') {
            //Countdown project time
            if(isset($node->field_project_end_time)) {
                $end_time = strtotime($node->field_project_end_time[$node->language][0]['value']);
                $now = time();
                if($end_time > $now) {
                    $count_down = $end_time - $now;
                    $day = date("d",$end_time);
                    $month = date("m",$end_time);
                    $year = date("Y",$end_time);
                    $pj_js = '(function($){

                        })(jQuery);';
                    drupal_add_js($pj_js,array('type' => 'inline','scope' => 'footer'));
                    drupal_add_js(array('pjEndtime' => array('day' => $day, 'month' => $month, 'year' => $year),'nid' => $node->nid),'setting');
                }
            }
        }
        if($node->type == 'event') {
            if(isset($node->field_event_start_time)) {
                //kpr($node->field_event_start_time);die;
                $start_time = $node->field_event_start_time[$node->language][0]['value'];
                $event_js = '(function($){
                        // Event Countdown
                            $(document).ready(function(){
                                if($(".countdown").size() > 0) {
                                    $(".countdown").downCount({
                                        date: "'.$start_time.'",
                                        offset: +10
                                    }, function () {
                                        alert("Event done!");
                                    });
                                }
                            });
                        })(jQuery);
                            ';
                drupal_add_js($event_js,array('type' => 'inline','scope' => 'footer'));
            }
        }
        if($node->type == 'product') {
            // Template suggestion for node teaser of product
            if($variables['view_mode'] == 'teaser') {
                $variables['theme_hook_suggestions'][] = 'node__' . $variables['node']->type . '__teaser';
                $variables['theme_hook_suggestions'][] = 'node__' . $variables['node']->nid . '__teaser';
            } else {
                $variables['theme_hook_suggestions'][] = 'node__' . $variables['node']->type . '__default';
                $variables['theme_hook_suggestions'][] = 'node__' . $variables['node']->nid . '__default';
            }
        }
    }
}